package com.xjh.utils.resultutils;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author wcy
 */
@Data
public class PageResult<E extends Serializable> implements Serializable {

    private static final long serialVersionUID = -8086169844802444430L;

    private Long total;

    private List<E> records;

    public static <E extends Serializable> PageResult<E> createFor(Long total, List<E> records) {
        PageResult<E> pageResult = new PageResult<>();
        pageResult.setTotal(total);
        pageResult.setRecords(records);
        return pageResult;
    }

    public static <E extends Serializable> PageResult<E> createFor(Integer total, List<E> records) {
        PageResult<E> pageResult = new PageResult<>();
        pageResult.setTotal(total.longValue());
        pageResult.setRecords(records);
        return pageResult;
    }
}
